package com.example;

import com.example.bean.Orders;
import com.example.bean.Product;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Date;
import java.util.concurrent.Executor;


public class App2 {
    public static void main(String[] args) {
        ApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig2.class);

        Orders orders = (Orders) ac.getBean("orders");
        System.out.println(orders);
        Product product=(Product) ac.getBean("p1");
        System.out.println(product);
        Executor executor=(Executor) ac.getBean("threadPool");
        executor.execute(  ()->{
            while(true){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(new Date());
            }
        });
    }
}
